/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    Image,
    ListView,
    TouchableOpacity
} from 'react-native';

var LazyFoodsCell =require('./LazyFoodsCell');
var dataAttr = require('../../LocalData/foodsData.json');
var LazyFoodsList = React.createClass({
    getInitialState(){
        var ds = new ListView.DataSource({rowHasChanged:(row1, row2) => row1 !== row2});

        return{
            dataSource: ds.cloneWithRows(dataAttr)
        }
    },
    render() {
        return (
            <ListView
                dataSource={this.state.dataSource}
                renderRow={this.renderRows}
                style={{marginBottom:60}}
            />
        );
    },
    // 具体的cell
    renderRows(rowdata,sectionID,rowID){
        return(
            <View>
                <LazyFoodsCell
                    image={rowdata.image}
                    name={rowdata.name}
                    price={rowdata.price}
                    date={rowdata.date}
                    address={rowdata.address}
                    free={rowdata.free}
                />
            </View>
        );
    }
});
const styles = StyleSheet.create({
    container: {
        flex:1
    },
});
module.exports = LazyFoodsList;